import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart';
import 'package:member_center_sdk_example/components/loading_button.dart';

import 'action.dart';
import 'state.dart';

Widget buildView(
    PwdLoginState state, Dispatch dispatch, ViewService viewService) {
  return Container(
    child: Column(
      children: <Widget>[
        new Container(
          child: new TextField(
            controller: state.userNameController,
            decoration: InputDecoration(
                icon: Icon(Icons.account_box), labelText: "用户名"),
          ),
          padding: EdgeInsets.all(30),
        ),
        Divider(
          height: 0.2,
        ),
        new Container(
          child: new TextField(
            controller: state.passwordController,
            obscureText: true,
            decoration:
                InputDecoration(icon: Icon(Icons.lock), labelText: "密码"),
          ),
          padding: EdgeInsets.all(30),
        ),
        new Container(
          child: LoadingButton("立即登录", state.isLoading, () {
            dispatch(PwdLoginActionCreator.onLoginAction());
          }),
        ),
        new Container(
          padding: EdgeInsets.all(25),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              GestureDetector(
                onTap: () {
                  dispatch(PwdLoginActionCreator.onSwitchAction());
                },
                child: Text(
                  "验证码登录",
                  style: TextStyle(
                      fontSize: 16, decoration: TextDecoration.underline),
                ),
              ),
              new Container(),
              GestureDetector(
                onTap: () {
                  dispatch(PwdLoginActionCreator.onRegisterAction());
                },
                child: Text(
                  "注 册",
                  style: TextStyle(
                      fontSize: 16, decoration: TextDecoration.underline),
                ),
              ),
            ],
          ),
        ),
      ],
    ),
  );
}
